package yygh.task.schedule;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import yygh.rabbitmq.Service.RabbitService;
import yygh.rabbitmq.constant.MqConst;


/**
 *  实现定时任务的提醒
 */
@Component
@EnableScheduling
public class ScheduleTask {

    @Autowired
    RabbitService rabbitService;

    /**
     * 定时发送消息给mq队列，提醒就诊人就医
     */
    //cron表达式，设置执行间隔
    //https://cron.qqe2.com/,cron在线表达式生成，例如
    //0 0 8 * * ? 代表每天8点提醒
    //3 * * * * ? 代表每3s发送一次
    @Scheduled(cron = "0/30 * * * * ?")
    public  void taskPatient(){
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_8,"");
    }
}


